{% extends "admin/change_form.html" %}
{% comment %}
# change_form.html
# Author: Nico Marrero
# Copyright 2012 Nico Marrero
#
#	 This file is part of django-serenity.
#
#    django-serenity is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    django-serenity is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with django-serenity.  If not, see <http://www.gnu.org/licenses/>.
{% endcomment %}

{% load adminmedia admin_list i18n admin_modify %}
{% load serenity_tags %}

{% block title %}{% if Character.name %}{{Character.name}}{% else %}Creating New Character{% endif %}{% endblock title %}
{% block extrastyle %}
	{{block.super}}
	<link rel="stylesheet/less" type="text/css" href="{{STATIC_URL}}serenity/serenity.less">
	<script src="http://lesscss.googlecode.com/files/less-1.3.0.min.js" type="text/javascript"></script>
{% endblock extrastyle %}

{% block breadcrumbs %}{% if not is_popup %}
<div class="breadcrumbs">
     <a href="../../../">{% trans "Home" %}</a> &rsaquo;
     <a href="../../">{{ app_label|capfirst|escape }}</a> &rsaquo;
     <a href="../">{{ opts.verbose_name_plural|capfirst }}</a> &rsaquo;
     {% if add %}{% trans "Add" %} {{ opts.verbose_name }}{% else %}{{ original|truncatewords:"18" }}{% endif %}
</div>
{% endif %}{% endblock %}

{% block content_title %}{% endblock content_title %}
{% block content %}
	<div id="content-main">
		{% if Character.dead %}
			<h2 class="alert">{{Character.name}} is dead!</h2>
		{% else %}{% if Character.knocked_senseless %}
			<h2 class="alert">{{Character.name}} has been knocked senseless!</h2>
		{% else %}{% if Character.passed_out %}
			<h2 class="alert">{{Character.name}} has passed out!</h2>
		{% endif %}{% endif %}{% endif %}
		<form action="{{ form_url }}" method="post" id="{{ opts.module_name }}_form">{% csrf_token %}
				{% if errors %}
					<p class="errornote">
					{% blocktrans count errors|length as counter %}Please correct the error below.{% plural %}Please correct the errors below.{% endblocktrans %}
					</p>
					{{ adminform.form.non_field_errors }}
					{{ adminform.form.errors }}
				{% endif %}
				<button type="submit" class="FloatingSaveButton" name="_continue" value="Save and continue editing" title="Save Current Progress">Save</button>
			<div class="serenity_charactersheet">
				<img class="serenity_charactersheet_background" src="{{STATIC_URL}}serenity/charactersheet.png">
				{% for name,data in CharacterDict.items %}
					<span class="serenity_{{name}}">
						{% if name not in show_specific_fields %}
							{% if perms.serenity.change_all_serenitycharacters or not CharacterDict.approved_by %}
								{% if name in adminform.form.fields %}
									{% with field=adminform.form|getitem:name %}
										{{field}}
									{% endwith %}
								{% else %}
									<span class="text_shift">{{data|spacify}}</span>
								{% endif %}
							{% else %}
								<span class="text_shift">{{data|spacify}}</span>
							{% endif %}
						{% endif %}
					</span>
				{% endfor %}
				<span class="serenity_equipment">{{adminform.form.equipment}}</span>
				<fieldset class="serenity_currency">
					<legend>Currency</legend>
					<table border="0" cellspacing="0" cellpadding="0">
						<tr>
							<td rowspan="3"><span class="serenity_credits" title="Total Currency in Credits: {{adminform.form.instance.total_in_credits}}">Credits: {{adminform.form.credits}}</span></td>
							<td class="center"><span class="serenity_platinum" title="Total Currency in Platinum: {{adminform.form.instance.total_in_platinum}}">Platinum:</span></td>
							<td>{{adminform.form.platinum}}</td>
							</td>
						</tr>
						<tr><td class="center"><span class="serenity_gold" title="Total Currency in Gold: {{adminform.form.instance.total_in_gold}}">Gold:</span></td><td>{{adminform.form.gold}}</td></tr>
						<tr><td class="center"><span class="serenity_silver" title="Total Currency in Silver: {{adminform.form.instance.total_in_silver}}">Silver:</span></td><td>{{adminform.form.silver}}</td></tr>
					</table>
				</fieldset>
				<span class="serenity_nickname">{{adminform.form.nickname}}</span>
				<span class="serenity_description"><h2>Description:</h2>{{adminform.form.description}}</span>
				<span class="serenity_notes"><h2>Notes:</h2>{{adminform.form.notes}}</span>
				<span class="serenity_history">
					{% if perms.serenity.change_all_serenitycharacters or not CharacterDict.approved_by %}<h2>History:</h2>{{adminform.form.history}}
					{% else %}{% if CharacterDict.history %}<h2>History:</h2><span class="serenity_history_content">{{CharacterDict.history|linebreaksbr}}</span>{% endif %}{% endif %}
				</span>
				
				{% if Weapon %}
					<span class="serenity_weapon_button button"><a href="/serenity/serenitycharacterweapon/{{Weapon.id}}/" title="Change Weapons"><img src="{{STATIC_URL}}serenity/weaponbutton.png"></a></span>
					{% for dummy in 123|make_list %}
						{% with weapon_num=forloop.counter|stringformat:"s" %}
						{% with weapon="weapon"|add:weapon_num %}
						{% with weapon_ammo_str=weapon|add:"_ammo" %}
						{% with weapon_data=Weapon|getitem:weapon %}
						{% with weapon_ammo=Weapon|getitem:weapon_ammo_str %}
							{% if weapon_data %}
								<span class="serenity_{{weapon}}_name">{{weapon_data.name|spacify}}</span>
								<span class="serenity_{{weapon}}_type">{{weapon_data.type|spacify}}</span>
								<span class="serenity_{{weapon}}_damage">{{weapon_data.damage|spacify}}</span>
								<span class="serenity_{{weapon}}_range">{{weapon_data.range|spacify}}</span>
								<span class="serenity_{{weapon}}_rate">{{weapon_data.rate|spacify}}</span>
								<span class="serenity_{{weapon}}_ammo">{{weapon_ammo}}/{{weapon_data.ammo|spacify}}</span>
							{% endif %}
						{% endwith %}
						{% endwith %}
						{% endwith %}
						{% endwith %}
						{% endwith %}
					{% endfor %}
				{% endif %}
				{% if Armor %}
					<span class="serenity_armor_button button"><a href="/serenity/serenitycharacterarmor/{{Armor.id}}/" title="Change Armor"><img src="{{STATIC_URL}}serenity/armorbutton.png"></a></span>
					<span class="serenity_armor_name">{{Armor.armor.name|spacify}}</span>
					<span class="serenity_armor_type">{{Armor.armor.type|spacify}}</span>
					<span class="serenity_armor_rating">{{Armor.armor.rating|spacify}}</span>
					<span class="serenity_armor_covers">{{Armor.armor.covers|spacify}}</span>
					<span class="serenity_armor_penalty">{{Armor.armor.penalty|spacify}}</span>
				{% endif %}
				
				{% if perms.serenity.change_all_serenitycharacters and 'player' in adminform.form.fields %}<span class="serenity_player">{{adminform.form.player}}</span>
				{% else %}<span class="serenity_playername">
							{% if adminform.form.instance.player %}
								{{adminform.form.instance.player.first_name}}&nbsp;{{adminform.form.instance.player.last_name.0}}
							{% endif %}
						  </span>
				{% endif %}
				<span class="serenity_life_points" title="Vitality + Willpower">{{adminform.form.instance.life_points}}</span>
				<span class="serenity_endurance" title="Vitality + Willpower">{{adminform.form.instance.endurance|spacify}}</span>
				<span class="serenity_initiative" title="Agility + Alertness">{{adminform.form.instance.initiative|spacify}}</span>
				<span class="serenity_resistance" title="2x Vitality">{{adminform.form.instance.resistance|spacify}}</span>

				<button class="serenity_wound0 button" type="submit" name="wounds" value="0" title="Resets wounds taken to 0"><img src="{{STATIC_URL}}serenity/woundbutton.png"></button>
				<button class="serenity_stun0 button" type="submit" name="stuns" value="0" title="Resets stuns taken to 0"><img src="{{STATIC_URL}}serenity/stunbutton.png"></button>
				{% for dummy in 1234567890123456789012|make_list %}
					<button class="serenity_wound{{forloop.counter}}{% if Character.wounds_taken >= forloop.counter %} damaged{% endif %}" type="submit" name="wounds" value="{{forloop.counter}}">{{forloop.counter}}</button>
					<button class="serenity_stun{{forloop.counter}}{% if Character.stuns_taken >= forloop.counter %} damaged{% endif %}" type="submit" name="stuns" value="{{forloop.counter}}">{{forloop.counter}}</button>
				{% endfor %}
				
				{% if perms.serenity.change_all_serenitycharacters or not CharacterDict.approved_by %}
					<span class="serenity_asset_button button"><a href="/serenity/serenitycharacterasset/" title="Change Assets"><img src="{{STATIC_URL}}serenity/assetbutton.png"></a></span>
				{% endif %}
				{% for asset in Assets %}
					<span class="serenity_asset{{forloop.counter}}_name">{{asset.asset.name|spacify}}</span>
					<span class="serenity_asset{{forloop.counter}}_{{asset.asset.get_level_display}}">x</span>
					<span class="serenity_asset{{forloop.counter}}_description">{{asset.asset.description}}{% if asset.specialization %} ({{asset.specialization}}){% endif %}</span>
				{% endfor %}
				{% if perms.serenity.change_all_serenitycharacters or not CharacterDict.approved_by %}
					<span class="serenity_complication_button button"><a href="/serenity/serenitycharactercomplication/"  title="Change Complications"><img src="{{STATIC_URL}}serenity/complicationbutton.png"></a></span>
				{% endif %}
				{% for complication in Complications %}
					<span class="serenity_complication{{forloop.counter}}_name">{{complication.complication.name|spacify}}</span>
					<span class="serenity_complication{{forloop.counter}}_{{complication.complication.get_level_display}}">x</span>
					<span class="serenity_complication{{forloop.counter}}_description">{{complication.complication.description}}{% if complication.specialization %} ({{complication.specialization}}){% endif %}</span>
				{% endfor %}
				
				{% if perms.serenity.change_all_serenitycharacters or not CharacterDict.approved_by %}
					<span class="serenity_skill_button button"><a href="/serenity/serenitycharacterskillspecialty/" title="Change Skill Specialties"><img src="{{STATIC_URL}}serenity/skillbutton.png"></a></span>
				{% endif %}
				{% for skill, specialties in Specialties.items %}
					{% for specialty in specialties %}
						<span class="serenity_{{skill}}_{{forloop.counter}}_name" title="{{specialty.specialty|spacify}}">{{specialty.specialty|spacify}}</span>
						<span class="serenity_{{skill}}_{{forloop.counter}}_level">{{specialty.get_level_display}}</span>
					{% endfor %}
				{% endfor %}
			</div>
		</form>
	</div>
{% endblock content %}